// 选项卡
{
    const aBtn = document.querySelectorAll('.maincon ul>li')
    const aBox = document.querySelectorAll('.body')
    // console.log(aBox)
    // console.log(aBtn)
    // const sjBoxHover = document.querySelectorAll('.sj .tabbox ul')

    // divHover(sjBoxHover)
    TAB(aBtn, aBox)

    function TAB(btn, box) {
        btn.forEach(function (ele, index) {
            btn[index].addEventListener('click', function () {
                for (let i = 0; i < btn.length; i++) {
                    btn[i].classList.remove('on')
                    box[i].classList.remove('on')
                }
                btn[index].classList.add('on')
                box[index].classList.add('on')
            })
        })
    }
}




// 抖音和微信滑过出现二维码
{
    const oGzh = document.querySelector('.gzh')
    const oDy = document.querySelector('.dy')
    const oWeixin = document.querySelector('.weixin')
    const oDou = document.querySelector('.douyin')
    oGzh.addEventListener('mouseover', function () {
        oWeixin.style.display = 'block'
    })
    oGzh.addEventListener('mouseout', function () {
        oWeixin.style.display = 'none'
    })
    oDy.addEventListener('mouseover', function () {
        oDou.style.display = 'block'
    })
    oDy.addEventListener('mouseout', function () {
        oDou.style.display = 'none'
    })
}



// 返回顶部
{
    const oNav = document.querySelector('.nav')
    const oTop = document.querySelector('.nav .top')
    window.onscroll = function () {
        var dis = document.body.scrollTop || document.documentElement.scrollTop
        if (dis >= 185) {
            oNav.style.display = 'block'
            // oNav.style.height = 300 + 'px'
        } else {
            oNav.style.display = 'none'
            // oNav.style.height = 224 + 'px'
        }
    }
    oTop.onclick = function () {
        document.body.scrollTop = 0
        document.documentElement.scrollTop = 0
    }
}



// 添加专栏
{
    const oBlist = document.querySelector('.biglist')
    const oShuru = document.querySelector('.shuru')
    const oQx = document.querySelector('.quanxian')
    const oSrzl = document.querySelector('.srzl')
    // const aDanxuan = document.querySelectorAll('.kejian input')
    const aDanxuan = document.getElementsByName('value')
    const oPro = document.querySelector('.pro')
    // var a
    const oClose = document.querySelector('.close')
    const oTianjia = document.querySelector('.tianjia')
    const oWode = document.querySelector('.wode')
    const oMe = document.querySelector('.me')
    const oMask = document.querySelector('.mask')

    oPro.addEventListener('click', function () {

        oShuru.innerHTML += oSrzl.value
        for (var i = 0; i < aDanxuan.length; i++) {
            // console.log(aDanxuan[i])
            if (aDanxuan[i].checked) {
                // a = aDanxuan[i].value
                oQx.innerHTML = aDanxuan[i].value
            }
            if (aDanxuan[i].value !== '') {
                oMask.style.display = 'block'
                // if (oShuru !== '') {
                //     oMask.style.display = 'none'
                // }
            }
//             oBlist.innerHTML += `<div class="list">
//     <a href="">
//         <img src="https://kuangstudy.oss-cn-beijing.aliyuncs.com/bbs/2021/08/16/kuangstudy0ff38edc-4f3e-477a-9655-314a8f28d55b.jpg"
//             alt="">
//         <p class="shuru">${oSrzl.value}</p>
//         <div class="p liulan">
//             <h3>浏览数：0 / 2022-07-26</h3>
//             <span class="quanxian">${aDanxuan[i].value}</span>
//         </div>
//     </a>
// </div>`
        }
        // if (aDanxuan[i].value !== '') {
        //     oMask.style.display = 'block'
        // }
    })

    oClose.addEventListener('click', function () {
        oTianjia.style.display = 'none'
        oWode.classList.add('on')
        oMe.classList.add('on')
    })
    // window.onload = function () {
    // for (var i = 0; i < aDanxuan.length; i++) {
    //         console.log(aDanxuan[i])
    //         if (aDanxuan[i].checked) {
    //             // a = aDanxuan[i].value
    //             oQx.innerHTML = aDanxuan[i].value
    //         }
    //     }
    // }
}



{
    let oBiglist = document.querySelector('.quanbu .biglist')
    console.log(oBiglist)
    ajax({
        url: 'http://192.168.10.28:8080/qfCourseContent/selectAll',
        type: 'get',
        data: {},
        success(res) {
            let json = JSON.parse(res)
            console.log(json)
            console.log(json.data[0].qfCourse[0].name)
            json.data.forEach((ele)=> {
                oBiglist.innerHTML += `<div class="list">
                <a href="">
                    <img src="https://kuangstudy.oss-cn-beijing.aliyuncs.com/bbs/2021/08/16/kuangstudy0ff38edc-4f3e-477a-9655-314a8f28d55b.jpg"
                        alt="">
                    <div class="p">
                        <h3>${ele[0].qfCourse[0].name}</h3>
                        <span>所有人可见</span>
                    </div>
                </a>
            </div>`
            })
        }
    })
}
